import request from '@/config/axios'

/** 班级学生信息 */
export interface CourseStudentRegistForm {
          id: number; // 课程学生报名表ID
          studentId?: number; // 学生ID
          classId?: number; // 课程ID
          duration: number; // 授课时长
          restDuration: number; // 剩余授课时长
          orderIds?: number[];
  }

// 班级学生 API
export const CourseStudentRegistFormApi = {
  // 查询班级学生分页
  getCourseStudentRegistFormPage: async (params: any) => {
    return await request.get({ url: `/train/course-student-regist-form/page`, params })
  },

  // 查询班级学生列表
  getCourseStudentRegistFormListByClassesId: async (classesId: number) => {
    return await request.get({ url: `/train/course-student-regist-form/listByClassesId?classesId=` + classesId })
  },

  // 查询班级学生详情
  getCourseStudentRegistForm: async (id: number) => {
    return await request.get({ url: `/train/course-student-regist-form/get?id=` + id })
  },

  // 新增班级学生
  createCourseStudentRegistForm: async (data: CourseStudentRegistForm) => {
    return await request.post({ url: `/train/course-student-regist-form/create`, data })
  },

  // 批量新增班级学生
  createCourseStudentRegistFormList: async (classesId:number, ids: number[]) => {
    return await request.post({ url: `/train/course-student-regist-form/create-list?classesId=` + classesId + `&ids=${ids.join(',')}` })
  },

  // 修改班级学生
  updateCourseStudentRegistForm: async (data: CourseStudentRegistForm) => {
    return await request.put({ url: `/train/course-student-regist-form/update`, data })
  },

  // 删除班级学生
  deleteCourseStudentRegistForm: async (id: number) => {
    return await request.delete({ url: `/train/course-student-regist-form/delete?id=` + id })
  },

  /** 批量删除班级学生 */
  deleteCourseStudentRegistFormList: async (ids: number[]) => {
    return await request.delete({ url: `/train/course-student-regist-form/delete-list?ids=${ids.join(',')}` })
  },

  // 导出班级学生 Excel
  exportCourseStudentRegistForm: async (params) => {
    return await request.download({ url: `/train/course-student-regist-form/export-excel`, params })
  },

  // 查询班级人数
  getStudentCount: async (classesId: number) => {
    return await request.get({ url: `/train/course-student-regist-form/getCount?classesId=` + classesId })
  },
}
